package com.qf.controller;

import com.github.pagehelper.PageInfo;
import com.qf.entity.TUser;
import com.qf.service.IUserService;
import com.qf.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * <p>title: com.qf.controller</p>
 * description:
 */
@Controller
public class UserController {

    @Autowired
    private IUserService userService;


    @RequestMapping("findPage")
    public String findPage(Model model, @RequestParam(defaultValue = "1") String page, @RequestParam(defaultValue = "5") String size){


        PageInfo<TUser> pageInfo = userService.selectPage(page, size);


        PageResult<TUser> pageResult = new PageResult<>();
        pageResult.setTotal(pageInfo.getTotal());
        pageResult.setData(pageInfo.getList());

        model.addAttribute("result", pageResult);

        return "user";

    }


}